Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes NATIVE_INT_TYPE, NATIVE_UINT_TYPE, and POINTER_CAST from Fw #3286

Open
wants to merge 18 commits into
base: devel
Choose a base branch
from

Conversation

LeStarch
Copy link
Collaborator

@LeStarch LeStarch commented Feb 27, 2025

Related Issue(s)
Has Unit Tests (y/n)
Documentation Included (y/n)

Change Description

NATIVE_INT_TYPE, NATIVE_UINT_TYPE, and POINTER_CAST from Fw. It fixes issues outside of Fw where changes affected dependents.

Rationale

Fixes #3206.

Testing/Review Recommendations

This PR needs careful review. When switching types the following requirements on the types were determined. Reviewers must agree with these new guarantees to merge this PR. Additionally, other implicit requirements on the types chosen should be looked for while reviewing.

Reviewers should:

  1. Check the boxes below indicating agreement with the new (tighter) specifications
  2. Review the code
  3. Update the lists below to include any missed requirements.

@thomas-bc accepts:

  • FwEnumStoreType is signed
    • Rationale: ID flag value of -1 is used in Fw
  • FwEnumStoreType is used to hold IDs (component IDs, thread IDs, object IDs, etc)
    • Rationale: FPP autocoder uses FwEnumStoreType to store IDs
  • FwSizeType can store the full range of U32
    • Fw.Buffer and other code store sizes as U32. Defining FwSizeType to a smaller range would cause issues converting back and forth. Assertions not possible because FwSizeType is also allowed to be larger and in these cases the assertions fail with "statement always true".
  • FwSignedSizeType is the same bit-width as FwSizeType but is signed rather than unsigned.
    • Rationale: conversion code in F Prime already assumes this fact.
  • Os::File size should not assert on negative sizes, but should respond with an error
    • Rationale: naive conversion from FwSizeType to FwSignedSizeType (e.g. static_cast) is caught by bad status, not prevented first
  • FwSizeType can store full range of FpDrframer::TokenType
    • Framer/Deframer uses "token type" as size. That must fit in F Prime (FwSizeType)

@LeStarch accepts:

  • FwEnumStoreType is signed
    • Rationale: ID flag value of -1 is used in Fw
  • FwEnumStoreType is used to hold IDs (component IDs, thread IDs, object IDs, etc)
    • Rationale: FPP autocoder uses FwEnumStoreType to store IDs
  • FwSizeType can store the full range of U32
    • Fw.Buffer and other code store sizes as U32. Defining FwSizeType to a smaller range would cause issues converting back and forth. Assertions not possible because FwSizeType is also allowed to be larger and in these cases the assertions fail with "statement always true".
  • FwSignedSizeType is the same bit-width as FwSizeType but is signed rather than unsigned.
    • Rationale: conversion code in F Prime already assumes this fact.
  • Os::File size should not assert on negative sizes, but should respond with an error
    • Rationale: naive conversion from FwSizeType to FwSignedSizeType (e.g. static_cast) is caught by bad status, not prevented first
  • FwSizeType can store full range of FpDrframer::TokenType
    • Framer/Deframer uses "token type" as size. That must fit in F Prime (FwSizeType)

@bocchino accepts:

  • FwEnumStoreType is signed
    • Rationale: ID flag value of -1 is used in Fw
  • FwEnumStoreType is used to hold IDs (component IDs, thread IDs, object IDs, etc)
    • Rationale: FPP autocoder uses FwEnumStoreType to store IDs
  • FwSizeType can store the full range of U32
    • Fw.Buffer and other code store sizes as U32. Defining FwSizeType to a smaller range would cause issues converting back and forth. Assertions not possible because FwSizeType is also allowed to be larger and in these cases the assertions fail with "statement always true".
  • FwSignedSizeType is the same bit-width as FwSizeType but is signed rather than unsigned.
    • Rationale: conversion code in F Prime already assumes this fact.
  • Os::File size should not assert on negative sizes, but should respond with an error
    • Rationale: naive conversion from FwSizeType to FwSignedSizeType (e.g. static_cast) is caught by bad status, not prevented first
  • FwSizeType can store full range of FpDrframer::TokenType
    • Framer/Deframer uses "token type" as size. That must fit in F Prime (FwSizeType)

@timcanham accepts:

  • FwEnumStoreType is signed
    • Rationale: ID flag value of -1 is used in Fw
  • FwEnumStoreType is used to hold IDs (component IDs, thread IDs, object IDs, etc)
    • Rationale: FPP autocoder uses FwEnumStoreType to store IDs
  • FwSizeType can store the full range of U32
    • Fw.Buffer and other code store sizes as U32. Defining FwSizeType to a smaller range would cause issues converting back and forth. Assertions not possible because FwSizeType is also allowed to be larger and in these cases the assertions fail with "statement always true".
  • FwSignedSizeType is the same bit-width as FwSizeType but is signed rather than unsigned.
    • Rationale: conversion code in F Prime already assumes this fact.
  • Os::File size should not assert on negative sizes, but should respond with an error
    • Rationale: naive conversion from FwSizeType to FwSignedSizeType (e.g. static_cast) is caught by bad status, not prevented first
  • FwSizeType can store full range of FpDrframer::TokenType
    • Framer/Deframer uses "token type" as size. That must fit in F Prime (FwSizeType)

Future Work

Note any additional work that will be done relating to this issue.

  1. Convert all U32 sizes to FwSizeType (e.g., in Fw::Buffer).
  2. Once item 1 is complete, remove the static assertion that FwSizeType has to hold a U32.

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Copy link
Collaborator Author

@LeStarch LeStarch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review comments

@LeStarch LeStarch requested a review from timcanham February 27, 2025 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non-Symantic Types: Fw
2 participants